# Maintainer: Forest Crossman <cyrozap at gmail dot com>

pkgname=stp
pkgver=2.3.3
pkgrel=11
pkgdesc="Simple Theorem Prover"
arch=('loong64' 'x86_64')
url="https://stp.github.io/"
license=('MIT')
depends=('boost-libs' 'cryptominisat' 'minisat')
makedepends=('boost' 'cmake' 'help2man' 'ninja' 'python')
source=("https://github.com/$pkgname/$pkgname/archive/$pkgver/$pkgname-$pkgver.tar.gz"
        'mandir.patch'
        'gcc-13.patch')
sha256sums=('ea6115c0fc11312c797a4b7c4db8734afcfce4908d078f386616189e01b4fffa'
            '4c09301c5a36cd89845a7177e1215008f8bbb23fa6f3c6cc941006825e28c327'
            'd6d4bae84e77890c3662b24852266d811d7c0d82ee8f98dd8b167a09cd1d2f74')

prepare() {
  # Correct the destination for man documentation.
  patch -d $pkgname-$pkgver < mandir.patch

  # Remove RPATH
  sed -i '/RPATH/d' $pkgname-$pkgver/{,tools/stp/,tools/stp_simple/}CMakeLists.txt

  # Fix build with GCC 13
  patch -d $pkgname-$pkgver -p1 < gcc-13.patch
}

build() {
  cmake -B build -S "$pkgname-$pkgver" \
    -DCMAKE_BUILD_TYPE=None \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DENABLE_PYTHON_INTERFACE=ON \
    -DCMAKE_INSTALL_LIBDIR=lib \
    -Wno-dev
  cmake --build build
}

package() {
  DESTDIR="$pkgdir" cmake --install build

  cd $pkgname-$pkgver
  install -Dm644 LICENSE LICENSE_COMPONENTS -t "$pkgdir"/usr/share/licenses/$pkgname/
}

# vim:set ts=2 sw=2 et:
